package com.wc.alorithm_blue_bridge._前缀和与差分.挖矿;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2025/3/5 20:25
 * @description
 * https://www.lanqiao.cn/courses/46292/learning/?id=3437007&compatibility=false
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 2000010;
    static int[] a = new int[N], ls = new int[N], rs = new int[N];
    static int n, m;

    public static void main(String[] args) {
        n = sc.nextInt();
        m = sc.nextInt();
        for (int i = 1; i <= n; i++) a[i] = sc.nextInt();
        for (int i = 1; i <= n; i++) {
            int x = a[i];
            if (x > 0) rs[x]++;
            else if (x < 0){
                x = -x;
                ls[x]++;
            } else rs[x]++;
        }
        for (int i = 1; i < N; i++) {
            rs[i] += rs[i - 1];
            ls[i] += ls[i - 1];
        }
        int res = 0;
        // 向左走 i 步, 向右就是 Math.max(0, m - 2 * i), 0 -> i -> 0 -> m - 2 * i
        // 向右走 i 步, 向左同理
        for (int i = 0; i <= m; i++) {
            int sum = ls[i] + rs[Math.max(0, m - 2 * i)];
            sum = Math.max(sum, ls[Math.max(0, m - 2 * i)] + rs[i]);
            res = Math.max(res, sum);
        }
        out.println(res);
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}

